package com.simple.datax.flow.util;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;

public class FailMessageUtil {
	private static final Logger log = Logger.getLogger(FailMessageUtil.class);

	private static LinkedBlockingQueue<String> msgQueen = new LinkedBlockingQueue<String>(10000);
	
	public static void addFailMessage(String msg) {
		if (msg != null) {
			try {
				boolean success = msgQueen.offer(msg);
			} catch (Exception e) {
				log.error("FailMessageUtil::addFailMessage ERROR:" + e.toString());
			}
		}
	}

	public static String getFailMessage() {
		String message = null;
		try {
			message = msgQueen.poll();
		} catch (Exception e) {
			log.error("FailMessageUtil::getFailMessage ERROR:" + e.toString());
		}
		return message;
	}
}
